{extend name="layout" /}
{block name="content"}
<div class="row">
  <div class="col-xs-3">
   <!--  <form>
    <div class="input-group input-group-sm">
        <input type="text" class="form-control input-sm" name="keywords">
        <span class="input-group-btn">
          <button type="button" class="btn btn-info btn-flat searchBtn" pageid="pages">搜  索</button>
        </span>
    </div>
    <input type="hidden" name="fieldset" value="keywords-name|title-like">
    </form> -->
  </div>
  <div class="col-xs-9" style="text-align: right">
    <button type="button" class="btn btn-success btn-sm cocoModal" isForm url="{:url('add')}" title="新增项目" fixat="1"><i class="fa fa-plus"></i> 新增</button>
    <button type="button" class="btn btn-default btn-sm cocoAjax" confirm="确定要更新缓存吗？" ajaxUrl="{:url('data_cache',array('model'=>$model))}"><i class="fa fa-retweet"></i> 更新缓存</button>
  </div>
</div>
  
<table class="layui-table" lay-data="{height: 'full-75', cellMinWidth: 80, page: true, limit:30, id:'lists', url:'{:url('data_show')}'}" lay-filter="lists">
  <thead>
    <tr class="layui-colla-content">
      <th lay-data="{type:'checkbox'}">ID</th>
      <th lay-data="{field:'id', sort: true}">ID</th>
      <th lay-data="{field:'title'}">名称</th>
      <th lay-data="{field:'description'}">简介</th>
      <th lay-data="{field:'statusname'}">状态</th>
      <th lay-data="{field:'addtime'}">添加时间</th>
      <th lay-data="{fixed: 'right', width:200, align:'center', toolbar: '#barDemo'}">操作</th>
  </thead>
</table>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-xs" lay-event="setrule">权限管理</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
{/block}
{block name="script"}
<script type="text/javascript">
  function setrule(data) {
    var layindex = layer.open({
      type: 2,
      area: ['800px', '530px'],
      fixed: false, //不固定
      maxmin: true,
      content: APP_URL+'/admin/authgroup/setrule?id='+data.id,
      title:'修改信息',
      btn: ['确定', '取消'],
      shade: [0.8, '#000000'],
      yes:function(index,layero){
        var iframeWin = window[layero.find('iframe')[0]['name']];
        formobj = iframeWin.$("form");
        ajaxUrl = formobj.attr("action");
        if(ajaxUrl == undefined || ajaxUrl == ''){
          ajaxUrl = defaultSaveUrl;
        }
        datajson = formobj.serialize();
        searchMap.postData = datajson;
        console.log(datajson);
        $.post(ajaxUrl,searchMap,function(datajson){
          var serializeObj={};
          if(datajson.status == 1){
            // $(formobj.serializeArray()).each(function(){  
            //   serializeObj[this.name]=this.value;  
            // });  
            // obj.update(serializeObj);
            layer.msg("操作成功",function(){
              layer.closeAll();
            });
            setTimeout(function() {
              location.reload();
            }, 300);
          }
          else{
            layer.msg(datajson.msg);
          }
        },'json');
      }
    });
  }
</script>
{/block}